import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class EmailMain {

	public static void main(String[] args) {
		try {
			File file = new File("/Users/houtouke/Desktop/彩妆护肤118万.txt");// Text文件
			BufferedReader br = new BufferedReader(new FileReader(file));// 构造一个BufferedReader类来读取文件
			String s = null;

			while ((s = br.readLine()) != null) {// 使用readLine方法，一次读一行

				if (s.endsWith("@163.com") || s.endsWith("@126.com")) {
					System.out.println(s);
					method1(s);
				}

			}
			br.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void method1(String s) {
		FileWriter fw = null;
		try {
			// 如果文件存在，则追加内容；如果文件不存在，则创建文件
			File f = new File("/Users/houtouke/Desktop/彩妆护肤118万2.txt");
			fw = new FileWriter(f, true);
		} catch (IOException e) {
			e.printStackTrace();
		}
		PrintWriter pw = new PrintWriter(fw);
		pw.println(s);
		pw.flush();
		try {
			fw.flush();
			pw.close();
			fw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
